
package com.insigma.business.qrcode.common.converter;



import com.insigma.business.qrcode.soldier.entity.PlacementWordConfigDO;
import com.insigma.business.qrcode.soldier.request.PlacementWordConfigBSearcher;
import com.insigma.business.qrcode.soldier.request.PlacementWordConfigInsertRequest;
import com.insigma.business.qrcode.soldier.request.PlacementWordConfigSearchRequest;
import com.insigma.business.qrcode.soldier.request.PlacementWordConfigUpdateRequest;
import com.insigma.business.qrcode.soldier.service.impl.PlacementWordConfigDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class PlacementWordConfigProviderConverter extends AbstractConverter<PlacementWordConfigDTO, PlacementWordConfigDO> {

    private final static PlacementWordConfigProviderConverter placementWordConfigConverter = new PlacementWordConfigProviderConverter();

    private PlacementWordConfigProviderConverter(){}

    
    public static PlacementWordConfigBSearcher convertRequestSO2Searcher(final PlacementWordConfigSearchRequest request){
        final PlacementWordConfigBSearcher placementWordConfigBSearcher = new PlacementWordConfigBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,placementWordConfigBSearcher);
        return placementWordConfigBSearcher;
    }

    
    public static PlacementWordConfigDO convertRequestUO2DO(final PlacementWordConfigUpdateRequest placementWordConfigUpdateRequest) {
        final PlacementWordConfigDO placementWordConfigDO = new PlacementWordConfigDO();
        BeanUtils.copyProperties(placementWordConfigUpdateRequest,placementWordConfigDO);
        
        return placementWordConfigDO;
    }

    
    public static PlacementWordConfigDO convertRequestIO2DO(final PlacementWordConfigInsertRequest placementWordConfigInsertRequest) {
        final PlacementWordConfigDO placementWordConfigDO = new PlacementWordConfigDO();
        BeanUtils.copyProperties(placementWordConfigInsertRequest,placementWordConfigDO);
        return placementWordConfigDO;
    }

    
    public static List<PlacementWordConfigDTO> convertResponseDOList2DTOList(final List<PlacementWordConfigDO> placementWordConfigDOList){
        return placementWordConfigConverter.convertGenericResponseDOList2DTOList(placementWordConfigDOList);
    }

    
    public static PlacementWordConfigDTO convertResponseDO2DTO(final PlacementWordConfigDO placementWordConfigDO){
        return placementWordConfigConverter.convertGenericResponseDO2DTO(placementWordConfigDO);
    }

    
    @Override
    protected PlacementWordConfigDTO doConvertResponseDO2DTO(PlacementWordConfigDO placementWordConfigDO) {
        final PlacementWordConfigDTO placementWordConfigDTO = new PlacementWordConfigDTO();
        try {
            BeanUtils.copyProperties(placementWordConfigDO, placementWordConfigDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return placementWordConfigDTO;
    }

}
